package com.ccs.hanke.service;

import com.ccs.hanke.design.CalDiscountfull100Strategy;
import com.ccs.hanke.design.CalStrategy;
import com.ccs.hanke.design.Caldiscount8Strategy;
import com.ccs.hanke.entity.Furit;
import com.ccs.hanke.entity.MarketFactory;

import java.util.HashMap;
import java.util.Scanner;

public class Problem04 {
    public static void main(String[] args) {


        Scanner scanner = new Scanner(System.in);
        String furitName;
        String furitweight;
        HashMap<Furit, Integer> map = new HashMap<Furit, Integer>();



        while (true) {
            System.out.print("请输入购买的水果名称（输入回车退出）：");
            furitName = scanner.nextLine();

            if (furitName.isEmpty()) {
                break;
            }

            System.out.print("请输入购买的水果总量：");
            furitweight = scanner.nextLine();

            MarketFactory marketFactory = new MarketFactory();
            Furit furit = marketFactory.getFurit(furitName.toLowerCase(), Integer.valueOf(furitweight));
            map.put(furit,Integer.valueOf(furitweight));

        }


        //策略3 100-10
        CalDiscountfull100Strategy calDiscountfull100Strategy = new CalDiscountfull100Strategy();

        double consumeCount = calDiscountfull100Strategy.calFuritSum(map);

        System.out.println("总花费："+consumeCount);











    }
}
